package com.qiku.controller;

import com.qiku.entity.Store;
import com.qiku.feign.StoreFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/page")
public class PageController {
    @Autowired
    private StoreFeign storeFeign;
    @GetMapping("/query")
    public List<Store> query(){
        List<Store> storeList = storeFeign.query();
        return storeList;
    }
    @GetMapping("/query/{id}")
    public Store queryById(@PathVariable Integer id){
        Store store = storeFeign.queryById(id);
        return store;
    }
    /**
     * 根据id删除
     * @param id
     */
    @GetMapping("/removeById")
    public void removeById(@PathVariable Integer id){
        storeFeign.removeById(id);
    }

    /**
     * 保存或者修改
     * @param store
     */
    @PostMapping("/saveOrUpdate")
    public void saveOrUpdate(@RequestBody Store store){
        storeFeign.saveOrUpdate(store);
    }
}
